package com.demo.controller;


import com.demo.entity.DvtWellsScoreItem;
import com.demo.entity.VteRiskScoreItem;
import com.demo.response.Result;
import com.demo.service.IDvtWellsScoreItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * dvt风险wells项目 前端控制器
 *
 * @author zm
 * @since 2020-11-25
 */
@RestController
@RequestMapping("/dvtWellsScoreItem")
@Api(tags = {"dvt风险wells项目"})
public class DvtWellsScoreItemController {
    @Autowired
    IDvtWellsScoreItemService dvtWellsScoreItemService;

    @ApiOperation("新增dvt风险wells项目")
    @PostMapping("/addDvtWellsScoreItem")
    public Result addDvtWellsScoreItem(@Validated @RequestBody DvtWellsScoreItem wellsScoreItem, BindingResult result) {
        if (result.hasErrors()) {
            return Result.error(result.getFieldError().getDefaultMessage());
        }
        return dvtWellsScoreItemService.addDvtWellsScore(wellsScoreItem);
    }

    @ApiOperation("更新dvt风险wells项目")
    @PostMapping("/updateDvtWellsScoreItem")
    public Result updateDvtWellsScoreItem(@RequestBody DvtWellsScoreItem wellsScoreItem, BindingResult result) {
        if (result.hasErrors()) {
            return Result.error(result.getFieldError().getDefaultMessage());
        }
        return dvtWellsScoreItemService.updateDvtWellsScore(wellsScoreItem);
    }

    @ApiOperation("删除dvt风险wells项目")
    @GetMapping("/deleteDvtWellsScoreItem")
    public Result deleteDvtWellsScoreItem(@RequestParam(name = "dvtItemId", required = true) Integer dvtItemId,
                                          @RequestParam(name = "deletedUserId", required = true) Integer deletedUserId) {
        return dvtWellsScoreItemService.deleteDvtWellsScore(dvtItemId, deletedUserId);
    }

    @ApiOperation("dvt风险wells项目列表")
    @GetMapping("/dvtWellsScoreItemList")
    public Result dvtWellsScoreItemList(@RequestParam(name = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                        @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                        @RequestParam(name = "dvtItemName", required = false) String dvtItemName,
                                        @RequestParam(name = "dvtItemMode", required = false) Integer dvtItemMode,
                                        @RequestParam(name = "dvtDiagnoseId", required = false) Integer dvtDiagnoseId,
                                        @RequestParam(name = "allItem", required = false, defaultValue = "false") Boolean allItem) {
        return dvtWellsScoreItemService.dvtWellsScoreList(pageNumber, pageSize, dvtItemName, dvtItemMode, dvtDiagnoseId, allItem);
    }

}
